#!/usr/bin/env python
# coding: utf-8
# author: Wesley

import hashlib

from django.conf import settings
from services.asyntask import youmengtask


class Base(object):
    def __init__(self, ostype):
        self.ostype = ostype

    def md5(self, s):
        m = hashlib.md5(s)
        return m.hexdigest()

    def push_unicast(self, device_token, payload, usertype):
        cfg = settings.YOUMEN_PUSH_KEY["%s_%s" % (self.ostype, usertype)]
        youmengtask.push_unicast.delay([cfg], device_token, payload)


ios_pusher = Base("1")
android_pusher = Base("0")
